<template>
	<view>
		<uni-card v-for="item,index in list" :title="item.content" thumbnail="" :extra="item.date" note="Tips">
			{{item.id}}
		</uni-card>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				"offset": 1,
				"pageIndex": 0,
				"pageSize": 10,
				list: [
					{
						"id": 1,
						"title": "Title ABCABC",
						"content": "Content ABCABC",
						"date": "2024-10-29",
						"name": "黄俊"
					},
					{
						"id": 2,
						"title": "Title ABCABC",
						"content": "Content ABCABC",
						"date": "2024-10-29",
						"name": "黄俊"
					}
				]
			}
		},
		onPullDownRefresh() {
			this.reload()
		},
		onReachBottom() {
			uni.showLoading({
				title: '正在加载',
				mask: false
			});
			uni.request({
				url: 'http://localhost:8090/freshmenapp/message/listByPage',
				method: 'POST',
				data: {
					"offset": this.offset,
					"pageIndex": this.pageIndex + 1,
					"pageSize": this.pageSize
			
				},
				success: res => {
					this.list = [...this.list, ...res.data.data]
					this.pageIndex = this.pageIndex + 1
					setTimeout(() => {
						uni.hideLoading()
					}, 3000)
			
				},
				fail: () => {},
				complete: () => {}
			});
		},
		methods: {
			reload() {
				uni.request({
					url: 'http://localhost:8090/freshmenapp/message/listByPage',
					method: 'POST',
					data: {
						"offset": this.offset,
						"pageIndex": 0,
						"pageSize": this.pageSize,
					},
					success: res => {
						if (res.data.success) {
							console.log(res.data);
							this.list = res.data.data
							uni.stopPullDownRefresh()
							uni.showToast({
								title: '刷新成功'
							});
						} else {

						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>

</style>